package com.bank.backend.boot.server.controller;


import com.bank.backend.boot.base.model.dto.BankBranchDTO;
import com.bank.backend.boot.base.model.response.Result;
import com.bank.backend.boot.server.service.BankBaseService;
import com.bank.backend.boot.server.service.BankBranchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 银行信息
 *
 * @author jiaowei
 * @since 2025/3/24 19:04
 */
@Slf4j
@Tag(name = "银行信息")
@RestController
@RequestMapping("/bank/info")
public class BankInfoController {
    @Resource
    private BankBaseService bankBaseService;

    @Resource
    private BankBranchService bankBranchService;


    @Operation(summary = "保存总行信息")
    @GetMapping("/saveBankBase/{name}")
    public Result saveBankBase(@PathVariable(value = "name") String name) {
        log.warn("总行信息入参：{}", name);
        boolean flag = bankBaseService.saveBankBase(name);
        if (flag) {
            return Result.success();
        }
        return Result.error("保存失败");
    }

    @Operation(summary = "保存支行信息")
    @PostMapping("/saveBankBranch")
    public Result saveBankBranch(@RequestBody BankBranchDTO bankBranchDTO) {
        log.warn("支行信息入参：{}", bankBranchDTO);
        boolean flag = bankBranchService.saveBankBranch(bankBranchDTO);
        if (flag) {
            return Result.success();
        }
        return Result.error("保存失败");
    }

}
